package com.youlu.campus.service.dict;

import com.youlu.campus.entity.DictConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictService {

    @Autowired
    private MongoTemplate mongoTemplate;

   public List<DictConfig> getByType(String type){
       Query query = new Query();
       query.addCriteria(Criteria.where("dicTypeName").is(type));
//       query.with(new Sort(Sort.Direction.ASC, "orderNumber"));
       Sort sort=Sort.by(Sort.Direction.ASC, "orderNumber");
       query.with(sort);
       return this.mongoTemplate.find(query,DictConfig.class);
   }
}
